package 剑指Offer.easy;

import java.util.LinkedList;

public class 圆圈中最后剩下的数字 {
    static class Solution {

        public static void main(String[] args) {
            Solution su = new Solution();
            int i = su.lastRemaining(5, 3);
            System.out.println(i);
        }
        public int lastRemaining(int n, int m) {
            int res = 0;
            for (int i = 2; i <= n; i++) {
                res = (res + m) % i;
            }
            return res;
        }
    }
}
